﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FlatRedBall.Input;

namespace ROMAP.Utilities
{
    public static class KeyboardManager
    {
        //get mouse x
        public static float getMouseX()
        {
            return InputManager.Mouse.WorldXAt(0);
        }

        //get mouse y
        public static float getMouseY()
        {
            return InputManager.Mouse.WorldYAt(0);
        }


        public static bool PressBothDirections()
        {
            return (InputManager.Keyboard.KeyDown(Microsoft.Xna.Framework.Input.Keys.A)
                    && InputManager.Keyboard.KeyDown(Microsoft.Xna.Framework.Input.Keys.D));
        }

        public static bool MoveRight()
        {
            return InputManager.Keyboard.KeyDown(Microsoft.Xna.Framework.Input.Keys.D)
                || (InputManager.Xbox360GamePads[0].LeftStick.Magnitude > .1f && InputManager.Xbox360GamePads[0].LeftStick.Position.X > 0)
                || InputManager.Xbox360GamePads[0].ButtonDown(Xbox360GamePad.Button.DPadRight);
        }

        public static bool MoveLeft()
        {
            return InputManager.Keyboard.KeyDown(Microsoft.Xna.Framework.Input.Keys.A)
                || (InputManager.Xbox360GamePads[0].LeftStick.Magnitude > .1f && InputManager.Xbox360GamePads[0].LeftStick.Position.X < 0)
                || InputManager.Xbox360GamePads[0].ButtonDown(Xbox360GamePad.Button.DPadLeft);
        }

        public static bool ReleaseMovement()
        {
            return (InputManager.Keyboard.KeyReleased(Microsoft.Xna.Framework.Input.Keys.A)
                || InputManager.Keyboard.KeyReleased(Microsoft.Xna.Framework.Input.Keys.D)
                || InputManager.Xbox360GamePads[0].LeftStick.Magnitude < .1f);
        }

        public static bool JumpStart()
        {
            return (InputManager.Mouse.ButtonPushed(Mouse.MouseButtons.LeftButton)
                || InputManager.Keyboard.KeyDown(Microsoft.Xna.Framework.Input.Keys.Space)
                || InputManager.Xbox360GamePads[0].ButtonDown(Xbox360GamePad.Button.A));
        }

        public static bool JumpRelease()
        {
            return InputManager.Mouse.ButtonReleased(Mouse.MouseButtons.LeftButton) 
                || InputManager.Keyboard.KeyReleased(Microsoft.Xna.Framework.Input.Keys.Space)
                || InputManager.Xbox360GamePads[0].ButtonReleased(Xbox360GamePad.Button.A);
        }

        public static bool Restart()
        {
            return InputManager.Keyboard.KeyDown(Microsoft.Xna.Framework.Input.Keys.R);
        }

        #region Debugging Purposes
        public static bool MoveUp()
        {
            return InputManager.Keyboard.KeyDown(Microsoft.Xna.Framework.Input.Keys.W);
        }

        public static bool MoveDown()
        {
            return InputManager.Keyboard.KeyDown(Microsoft.Xna.Framework.Input.Keys.S);
        }
        public static bool TestButton()
        {
            return InputManager.Keyboard.KeyPushed(Microsoft.Xna.Framework.Input.Keys.T);
        }
        #endregion
    }
}
